{% extends 'base.html' %}

{% block styles %}
{{ block.super }}
<link rel="stylesheet" type="text/css" title="style" href="{{ STATIC_URL }}css/event.css" />
{% endblock %}

{% block content %}
<!--{% if messages %}{% for message in messages %}
  {% if message.message == 'joined' %}
    <p>You have been successfully joined to this event.</p>
  {% endif %}
  {% if message.message == 'left' %}
    <p>You have been left from this event.</p>
  {% endif %}
  {% if message.message == 'participation_terms_changed' %}
    <p>You have successfully changed terms of participation.</p>
  {% endif %}
{% endfor %}{% endif %} -->
<ul id="event_members">
  <li id="title">Участники</li>
  {% for participation in event.participation_set.all %}
    <li id="member">
      <img id="member_avatar" src="{{ participation.user.avatar.url }}" alt="" width="118" height="118"/>
      <!--{{ participation.user.name }}( {{ participation.investment }}
      {% if with_patron and participation.patron %}
       +
      {% endif %}) -->
    </li>
  {% endfor %}
</ul>

<div id="event_content">
  <h1 id="event_name">{{ event.name }}</h1>
  <div id="event_info">
	<div id="event_info_left">  
      <p><span>Статус:</span>
       {% if event.status == Status.Scheduled %}
         Запланированно
       {% endif %}
	   {% if event.status == Status.Held %}
         Прошло
       {% endif %}
       {% if event.status == Status.Cancelled %}
         Отменено
       {% endif %}
      </p>
      <p><span>Город</span> {{ event.city }}</p>
	  <p><span>Дата:</span> {{ event.date }}</p>
	</div>
	<div id="event_info_right" class="right_text">
	  <ul id="right1">
	    <li><p><span>Участников:</span> {{ event.participants.count }}</p></li>
	    {% if event.max_participants_count %}
          <li><p><span>Максимум:</span> {{ event.max_participants_count }}</p></li>
        {% endif %}
	  </ul>
  	  
	  <ul id="right2">
        <li><p><span>Нужна сумма:</span> {{ event.cost }}</p></li>
        <li><p><span>Текущая:</span> {{ event.current_sum }}</p></li>
        <li><p><span>Текущая на участника:</span>
          {% if cost_status %}
            {{ event.current_sum_for_user }}
          {% else %}
            {{ event.current_sum_for_user }} (не хватает)
          {% endif %}
        </p></li>
        <li><p><span>Стретегия:</span>
        {{ event.strategy }}
        </p></li>
      </ul>	  
	</div>
  </div>
  <div id="event_description">
    <h2 id="description_title">Описание</h2> 
	<p id="description">{{ event.description }}</p>
  </div>
  
  <ul id="event_discussions">
    <li id="title" class="disc">Обсуждения</li>
    {% for discussion in event.discussions.all %}
      <li id="discussion"><a href="{% url core.views.event.discussion discussion.id %}">{{ discussion.name }}</a></li>
    {% endfor %}
    {% if user in event.participants.all %}
      <li id="no_discussion"><a href="{% url core.views.event.create_discussion event.id %}">Создать тему для обсуждения</a></li>
    {% endif %}
  </ul>
  
  <ul id="event_news">
    <li id="title" class="news">Новости</li>
    <li id="news"><a href="#">Новость</li>
      <li id="no_news"><a href="#">Создать новость</li>
  </ul>
</div>

<div id="event_right_block">
  <img id="event_logo" src="{{ event.logo.url }}" alt="" />
  {% if event.status == Status.Scheduled %}
      {% if event.owner == user %}
        <a id="event_edit" class="btn gray" href="{% url core.views.event.edit event.id %}">Редактировать</a>
      {% else %}
        {% if user not in event.participants.all %}
          {% if event.max_participants_count == event.participants.count %}
            You cannot join due to max participants count
          {% else %}
            <a id="event_join" class="btn gray" href="{% url core.views.event.join event.id %}">Присоединиться</a>
          {% endif %}
        {% else %}
          <a id="event_change_terms" class="btn gray" href="{% url core.views.event.change_participation_terms event.id %}">Изменить условия участия</a>
          <a id="event_leave" class="btn gray" href="{% url core.views.event.leave event.id %}">Покинуть мероприятие</a>
        {% endif %}
      {% endif %}
  {% endif %}
  <ul id="organizers">
    <li id="title">Организаторы</li> 
    <li id="organizers_info">
      <img id="avatar" src="{{ event.owner.avatar.url }}" alt="" width="44" height="44"/>
      <p>{{ event.owner }}</p>
      <p>{{ user.organization_raiting }}</p>
    </li>
  </ul>
</div>
{% endblock %}
